package com.itheima.springbootwebtlias.service.Impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.itheima.springbootwebtlias.mapper.OperateLogMapper;
import com.itheima.springbootwebtlias.pojo.OperateLog;
import com.itheima.springbootwebtlias.pojo.OperateLogQueryParam;
import com.itheima.springbootwebtlias.pojo.PageResult;
import com.itheima.springbootwebtlias.service.OperateLogService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Slf4j
@Service
public class OperateLogServiceImpl implements OperateLogService {

    @Autowired
    private OperateLogMapper operateLogMapper;

    @Override
    public PageResult page(OperateLogQueryParam queryParam) {
        PageHelper.startPage(queryParam.getPage(),queryParam.getPageSize());

        Page<OperateLog> page = (Page<OperateLog>) operateLogMapper.selectAll();

        PageResult pageResult = new PageResult(page.getTotal(),page.getResult());

        return pageResult;
    }
}
